package com.joysuch.wwyt.datadump.biz.condition;

import cn.zlg.common.datadump.condition.CustomQueryConditionBuilder;
import com.joysuch.wwyt.core.entity.dsl.QBaseUser;
import com.joysuch.wwyt.core.service.BaseUserService;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.SimpleExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BaseUserDumpFindSubdepartIdConditionBuilder implements CustomQueryConditionBuilder {

    @Autowired
    private BaseUserService baseUserService;

    @Override
    public Predicate build(String name, SimpleExpression propertyPath, Object value) {
        return QBaseUser.baseUser.departId.in(baseUserService.findDepartAndSubDepartIds((Long)value));
    }
}
